package com.cloudlead.plugin.dict.action;

import com.cloudlead.common.lang.annotation.Label;
import com.cloudlead.common.lang.persistence.Filter;
import com.cloudlead.common.lang.persistence.Page;
import com.cloudlead.common.lang.persistence.PageRequest;
import com.cloudlead.common.lang.persistence.Sort;
import com.cloudlead.common.worker.action.impl.AbstractCrudActionFactory;
import com.cloudlead.common.worker.annotation.Action;
import com.cloudlead.common.worker.annotation.Order;
import com.cloudlead.common.worker.annotation.ValidatorGroup;
import com.cloudlead.plugin.dict.BusinessModules;
import com.cloudlead.plugin.dict.action.validator.DictValidatorGroup;
import com.cloudlead.plugin.dict.service.DictService;
import com.cloudlead.plugin.dict.vo.Dict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * DictActionFactory is a Codegen action factory type
 */
@Controller("dictActionFactory")
@Label("字典管理")
public class DictActionFactory extends AbstractCrudActionFactory<DictService, Dict> {

    @Autowired
    public DictActionFactory(DictService service) {
        super(BusinessModules.Dict, service);
    }

    @Action
    @Order(1)
    @ValidatorGroup(DictValidatorGroup.Create.class)
    @Label("创建")
    @Override
    public Dict create(@NotNull Dict vo) {
        return super.create(vo);
    }

    @Action
    @Order(2)
    @ValidatorGroup(DictValidatorGroup.Update.class)
    @Label("更新")
    @Override
    public Dict update(@NotNull Dict vo) {
        return super.update(vo);
    }

    @Action
    @Order(3)
    @Label("批量更新")
    @Override
    public void updateAll(@NotNull Dict vo, @NotNull Filter filter) {
        super.updateAll(vo, filter);
    }

    @Action
    @Order(4)
    @Label("根据实例批量更新")
    @Override
    public void updateAllByExample(@NotNull Dict vo, @NotNull @Label("实例") Dict example) {
        super.updateAllByExample(vo, example);
    }

    @Action
    @Order(5)
    @Label("查看")
    @Override
    public Dict view(@NotNull @Label("编号") String id) {
        return super.view(id);
    }

    @Action
    @Order(6)
    @Label("单值查询")
    @Override
    public Dict findOne(@NotNull Filter filter) {
        return super.findOne(filter);
    }

    @Action
    @Order(7)
    @Label("根据实例单值查询")
    @Override
    public Dict findOneByExample(@NotNull @Label("实例") Dict example) {
        return super.findOneByExample(example);
    }

    @Action
    @Order(8)
    @Label("统计")
    @Override
    public long count(Filter filter) {
        return super.count(filter);
    }

    @Action
    @Order(9)
    @Label("根据实例统计")
    @Override
    public long countByExample(@NotNull @Label("实例") Dict example) {
        return super.countByExample(example);
    }

    @Action
    @Order(10)
    @Label("列表查询")
    @Override
    public List<Dict> list(Filter filter, Sort sort) {
        return super.list(filter, sort);
    }

    @Action
    @Order(11)
    @Label("根据实例列表查询")
    @Override
    public List<Dict> listByExample(@NotNull @Label("实例") Dict example) {
        return super.listByExample(example);
    }

    @Action
    @Order(12)
    @Label("分页查询")
    @Override
    public Page<Dict> findAll(@NotNull PageRequest pageable) {
        return super.findAll(pageable);
    }

    @Action
    @Order(13)
    @Label("删除")
    @Override
    public Dict delete(@NotNull @Label("编号") String id) {
        return super.delete(id);
    }

    @Action
    @Order(14)
    @Label("批量删除")
    @Override
    public void deleteAll(Filter filter) {
        super.deleteAll(filter);
    }

    @Action
    @Order(15)
    @Label("根据实例批量删除")
    @Override
    public void deleteAllByExample(@Label("实例") Dict example) {
        super.deleteAllByExample(example);
    }

}

